﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <jsp:include page="/common.jsp"></jsp:include>
</head>

<body class="navbar-top">
<div class="modal-shiftfix">
    <jsp:include page="/menu.jsp"></jsp:include>
    <div class="container-fluid main-content">
        <div class="widget-container fluid-height clearfix">
            <div class="heading clearfix">
                <i class="icon-table"></i> 联系人
                <a class="btn btn-sm btn-primary-outline pull-right"
                   href="${pageContext.request.contextPath}/LinkManServlet?method=toCreateLinkManView"><i
                    class="icon-plus"></i> 添加联系人</a></div>
            <div class="widget-content padded clearfix">
                <div class="dataTables_filter">
                    <%--搜索条件表单开始--%>
                    <form id="actionFormSo" action="${pageContext.request.contextPath}/LinkManServlet" method="post">
                        <div class="btn-group">
                            <input type="text" class="form-control input-sm" value="${param.mobile}" name="mobile"
                                   id="mobileId" placeholder="手机号">
                        </div>
                        <div class="btn-group">
                            <input type="text" class="form-control input-sm" value="${param.email}" name="email"
                                   id="emailId" placeholder="邮箱">
                        </div>
                        <div class="btn-group">
                            <button type="button" class="btn btn-success btn-sm" id="soo"><i
                                    class="glyphicon glyphicon-search"></i> 搜索
                            </button>
                        </div>
                    </form>
                    <%--搜索条件表单结束--%>
                </div>

                <div id="w0" class="grid-view">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>
                                    <label class="label-checkbox">
                                        <input type="checkbox" class="select-on-check-all" name="selection_all"
                                               value="1"><span class="custom-checkbox"></span></label>
                                </th>
                                <th nowrap>姓名</th>
                                <th nowrap>性别</th>
                                <th nowrap>尊称</th>
                                <th nowrap>职位</th>
                                <th nowrap>手机</th>
                                <th nowrap>电子邮箱</th>
                                <th nowrap>QQ</th>
                                <th nowrap>创建时间</th>
                                <th nowrap>更新时间</th>
                                <th class="action-column">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${linkManList}" var="linkMan">
                                <tr data-key="4">
                                    <td>
                                        <label class="label-checkbox">
                                            <input type="checkbox" name="selection[]" value="4"><span
                                                class="custom-checkbox"></span></label>
                                    </td>
                                    <td>${linkMan.name}</td>
                                    <td>${linkMan.sex}</td>

                                    <td>${linkMan.nickname}</td>

                                    <td>${linkMan.position}</td>
                                    <td>${linkMan.phonenum}</td>
                                    <td>${linkMan.email}</td>
                                    <td>${linkMan.qq}</td>
                                    <td>
                                        <fmt:formatDate value="${linkMan.createTime}" pattern="yyyy-MM-dd"/>
                                    </td>
                                    <td>
                                        <fmt:formatDate value="${linkMan.updateTime}" pattern="yyyy-MM-dd"/>
                                    </td>
                                    <td></td>
                                    <td>
                                        <button class="btn btn-success btn-sm"
                                                title="查看"
                                                aria-label="查看" onclick="examine('${linkMan.linkMainId}')">查看
                                        </button>
                                        <button class="btn btn-warning btn-sm"
                                                title="更新"
                                                aria-label="更新" onclick="updateLinkMan('${linkMan.linkMainId}')">修改
                                        </button>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <!--                         <div class="datatable-footer"> -->
                    <!--                             <div class="dataTables_info"> -->
                    <!--                                 <div class="pull-left">第<b>1-2</b>条，共<b>2</b>条数据.</div> -->
                    <!--                             </div> -->
                    <!--                             <div class="dataTables_paginate paging_full_numbers"></div> -->
                    <!--                         </div> -->
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("#soo").on("click", function () {
            var mobile = $("#mobileId").val();
            var email = $("#emailId").val();
            if ((mobile != null && mobile != "" && mobile != "undefined") || (email != null && email != "" && email != "undefined")) {
                $("#actionFormSo").attr("action", "LinkManServlet?method=searchLinkMan");
                $("#actionFormSo").submit();
            } else {
                $("#actionFormSo").attr("action", "LinkManServlet?method=getAllLinkMan");
                $("#actionFormSo").submit();
            }
        });
    });

    function examine(id) {
        location.href = '${pageContext.request.contextPath}/LinkManServlet?method=selectByPrimaryKey&linkMainId=' + id + '&type=1';
    }


    function updateLinkMan(id) {
        location.href = '${pageContext.request.contextPath}/LinkManServlet?method=selectByPrimaryKey&linkMainId=' + id;
    }

</script>
</body>

</html>
